{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "LangChain Agent代理的核心思想是使用LLM作为大脑自动思考，自动决策选择执行不同的动作，最终完成我们的目标任务。\n",
    "\n",
    "举个例子方便理解LangChain Agent要解决的问题。\n",
    "\n",
    "**例如：**\n",
    "\n",
    "我们要调研下“docker是否可以作为生产环境部署方案”，我们首先会去百度搜索”docker介绍”，浏览下搜索结果，然后进一步搜索”docker部署的优缺点”，浏览下结果等等，最后得出结论。\n",
    "\n",
    "LangChain Agent就是要模拟这个过程，我可以提前封装一序列工具（例如：百度搜索、提取URL内容等工具），然后给通过Agent下发一个目标任务“docker是否可以作为生产环境部署方案”，Agent就会构造提示词去调用大语言模型LLM，要实现这个目标任务，下一步执行什么动作（就是要调用那个工具），AI就会返回要调用的工具，代码就去执行这个工具，然后把工具执行的结果，回传给AI，再问下一步执行什么工具，反复执行这个过程就可以完成前面提到的任务。\n",
    "\n",
    "> 提示：这个是自从GPT模型发布以来，相当炸裂的能力，让LLM作为大脑，主动思考，然后调用我们开发好的各种API，这样LLM的能力就相当强大，目前这个特性还在实验阶段，会反复调用LLM所以相当费token，执行一个任务下来分分钟几万个token，想省钱，建议先让LLM执行简单的逻辑判断任务。\n",
    "\n",
    "## 核心概念\n",
    "\n",
    "下面介绍相关的组件&概念\n",
    "\n",
    "### Agent（代理）\n",
    "\n",
    "Agent可以理解成我们的助手，代理我们去做一些决策，在LangChain agent底层实现就是通过LLM决定下一步执行什么动作（或者说调用什么API），这里有个知名的ReAct模式，就是描述AI决策过程，感兴趣的同学可以去了解下。\n",
    "\n",
    "LangChain针对不同的场景提供了几种不同类型的代理类型。\n",
    "\n",
    "### Tools（工具）\n",
    "\n",
    "Tools我觉得理解成API更合适，就是我们提前封装好的各种功能的API，目的是扩展LLM的能力，由LLM根据问题决定调用那个具体的API来完成任务。\n",
    "\n",
    "### Toolkits（工具集合）\n",
    "\n",
    "工具集合，通常提供给LLM的工具不会是一个、两个，会提供一组可用的工具给LLM，让LLM完成任务的时候有更多的能力选择。\n",
    "\n",
    "### AgentExecutor\n",
    "\n",
    "代理执行器是负责执行LLM选择的工具（API）。以下是此运行时的伪代码：\n",
    "\n",
    "```bash\n",
    "# 通过LLM拿到需要执行的工具\n",
    "next_action = agent.get_action(...)\n",
    "# 如果没有完成任务，循环执行\n",
    "while next_action != AgentFinish:\n",
    "      # 执行动作\n",
    "    observation = run(next_action)\n",
    "    # 执行下一步要执行的工具\n",
    "    next_action = agent.get_action(..., next_action, observation)\n",
    "return next_action\n",
    "```\n",
    "\n",
    "执行过程虽然不复杂，执行器处理了很多细节问题主要包括：\n",
    "\n",
    "1. 处理agent选择不存在的工具的情况\n",
    "2. 处理工具出错的情况\n",
    "3. 处理agent产生无法解析为工具调用的输出的情况\n",
    "4. 调试问题。\n",
    "\n",
    "## 快速开始\n",
    "本节介绍LangChain的Agent的基础用法\n",
    "### 加载LLM"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "56c585d63b5e51c9"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "\n",
    "import os\n",
    "\n",
    "from dotenv import load_dotenv\n",
    "from langchain_openai import ChatOpenAI\n",
    "\n",
    "load_dotenv()\n",
    "llm = ChatOpenAI(\n",
    "    # 若没有配置环境变量，请用百炼API Key将下行替换为：api_key=\"sk-xxx\",\n",
    "    openai_api_key=os.getenv(\"DASHSCOPE_API_KEY\"),\n",
    "    openai_api_base=\"https://dashscope.aliyuncs.com/compatible-mode/v1\",\n",
    "    model_name=\"qwen-max\",\n",
    "    max_retries=0,\n",
    ")"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-30T09:21:46.081490Z",
     "start_time": "2024-10-30T09:21:45.989256Z"
    }
   },
   "id": "a527f19df764d03d",
   "execution_count": 71
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 定义工具\n",
    "定义一些工具，让Agent调用\n",
    ">注意：函数注释非常重要，它告诉LLM调用它能解决什么问题，get_word_length函数就是告诉LLM调用他可以计算单词长度。"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "830ca32571ed15fb"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "from langchain_core.tools import tool\n",
    "\n",
    "\n",
    "@tool\n",
    "def get_word_length(word: str) -> int:\n",
    "    \"\"\"\n",
    "    计算Word长度并返回计算结果\n",
    "    :param word: \n",
    "    :return: \n",
    "    \"\"\"\n",
    "    return len(word)\n",
    "\n",
    "\n",
    "@tool\n",
    "def send_sms(context: str, phone_number: str | list[str]) -> str:\n",
    "    \"\"\"\n",
    "    发送短信\n",
    "    :param context: \n",
    "    :param phone_number: \n",
    "    :return: \n",
    "    \"\"\"\n",
    "    print(f\"发短信，短信内容为：{context} 发送对象:{phone_number}\")\n",
    "    return \"发送成功\"\n",
    "\n",
    "\n",
    "# 定义工具集\n",
    "tools = [get_word_length, send_sms]"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-30T09:21:46.100699Z",
     "start_time": "2024-10-30T09:21:46.085037Z"
    }
   },
   "id": "488f1d2e3511523a",
   "execution_count": 72
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 创建提示\n",
    "现在让我们创建提示(prompt)。因为OpenAI Function Calling已经针对工具使用进行了优化，所以我们几乎不需要关于推理或输出格式的任何说明。只需两个输入变量：input和agent_scratchpad。input代表用户输入的问题，agent_scratchpad是agent的调用指令占位符，运行的时候会往提示词模板(prompt template)插入工具调用指令。"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "65541c58bc2d5a8a"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "\n",
    "from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder\n",
    "\n",
    "prompt = ChatPromptTemplate.from_messages([\n",
    "    (\"system\",\n",
    "     \"你是一个非常强大的助手，但不了解当前事件。\"),\n",
    "    (\"human\", \"{input}\"),\n",
    "    MessagesPlaceholder(variable_name=\"agent_scratchpad\"),\n",
    "])"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-30T09:21:46.106023Z",
     "start_time": "2024-10-30T09:21:46.102644Z"
    }
   },
   "id": "e2952d264be45d42",
   "execution_count": 73
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 工具绑定到LLM"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "7cbc9adcdd8eae"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "llm_with_tools = llm.bind_tools(tools)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-30T09:21:46.122769Z",
     "start_time": "2024-10-30T09:21:46.110468Z"
    }
   },
   "id": "afd4697e9daddf80",
   "execution_count": 74
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 创建代理\n",
    "将之前的内容整合在一起，将导入最后两个实用工具函数：一个用于将中间步骤（代理动作、工具输出）格式化为可发送给模型的输入消息的组件，另一个用于将输出消息转换为代理动作/代理结束。\n",
    "\n",
    ">`format_to_openai_tool_messages`工具格式化"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "d84c40ab76ff41df"
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001B[1m> Entering new None chain...\u001B[0m\n",
      "输出：{'agent_scratchpad': [], 'input': 'eudca这个单词有几个字母'}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9fc4f724dceb4986aa6064', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6e7227ca-92aa-4968-86d1-2aff78a5d0e2', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9fc4f724dceb4986aa6064', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9fc4f724dceb4986aa6064', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9fc4f724dceb4986aa6064')], 'input': 'eudca这个单词有几个字母'}\n",
      "\u001B[32;1m\u001B[1;3m单词 \"eudca\" 有5个字母。\u001B[0m\n",
      "\n",
      "\u001B[1m> Finished chain.\u001B[0m\n",
      "\n",
      "\n",
      "\u001B[1m> Entering new None chain...\u001B[0m\n",
      "输出：{'input': '给手机号18502820900,14812220909,18403009099，发送短信内容：明天下午到4楼会议室开会', 'agent_scratchpad': []}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `send_sms` with `{'context': '明天下午到4楼会议室开会', 'phone_number': ['18502820900', '14812220909', '18403009099']}`\n",
      "\n",
      "\n",
      "\u001B[0m发短信，短信内容为：明天下午到4楼会议室开会 发送对象:['18502820900', '14812220909', '18403009099']\n",
      "\u001B[33;1m\u001B[1;3m发送成功\u001B[0m输出：{'input': '给手机号18502820900,14812220909,18403009099，发送短信内容：明天下午到4楼会议室开会', 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_1d9bb4562d03406297f9d3', 'function': {'arguments': '{\"context\": \"明天下午到4楼会议室开会\", \"phone_number\": [\"18502820900\", \"14812220909\", \"18403009099\"]}', 'name': 'send_sms'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6581bc85-f41e-477c-bc18-61b294f4e37b', tool_calls=[{'name': 'send_sms', 'args': {'context': '明天下午到4楼会议室开会', 'phone_number': ['18502820900', '14812220909', '18403009099']}, 'id': 'call_1d9bb4562d03406297f9d3', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'send_sms', 'args': '{\"context\": \"明天下午到4楼会议室开会\", \"phone_number\": [\"18502820900\", \"14812220909\", \"18403009099\"]}', 'id': 'call_1d9bb4562d03406297f9d3', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='发送成功', tool_call_id='call_1d9bb4562d03406297f9d3')]}\n",
      "\u001B[32;1m\u001B[1;3m短信发送成功。内容是：明天下午到4楼会议室开会，已发送到手机号18502820900, 14812220909, 18403009099。\u001B[0m\n",
      "\n",
      "\u001B[1m> Finished chain.\u001B[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": "[{'actions': [ToolAgentAction(tool='send_sms', tool_input={'context': '明天下午到4楼会议室开会', 'phone_number': ['18502820900', '14812220909', '18403009099']}, log=\"\\nInvoking: `send_sms` with `{'context': '明天下午到4楼会议室开会', 'phone_number': ['18502820900', '14812220909', '18403009099']}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_1d9bb4562d03406297f9d3', 'function': {'arguments': '{\"context\": \"明天下午到4楼会议室开会\", \"phone_number\": [\"18502820900\", \"14812220909\", \"18403009099\"]}', 'name': 'send_sms'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6581bc85-f41e-477c-bc18-61b294f4e37b', tool_calls=[{'name': 'send_sms', 'args': {'context': '明天下午到4楼会议室开会', 'phone_number': ['18502820900', '14812220909', '18403009099']}, 'id': 'call_1d9bb4562d03406297f9d3', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'send_sms', 'args': '{\"context\": \"明天下午到4楼会议室开会\", \"phone_number\": [\"18502820900\", \"14812220909\", \"18403009099\"]}', 'id': 'call_1d9bb4562d03406297f9d3', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_1d9bb4562d03406297f9d3')],\n  'messages': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_1d9bb4562d03406297f9d3', 'function': {'arguments': '{\"context\": \"明天下午到4楼会议室开会\", \"phone_number\": [\"18502820900\", \"14812220909\", \"18403009099\"]}', 'name': 'send_sms'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6581bc85-f41e-477c-bc18-61b294f4e37b', tool_calls=[{'name': 'send_sms', 'args': {'context': '明天下午到4楼会议室开会', 'phone_number': ['18502820900', '14812220909', '18403009099']}, 'id': 'call_1d9bb4562d03406297f9d3', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'send_sms', 'args': '{\"context\": \"明天下午到4楼会议室开会\", \"phone_number\": [\"18502820900\", \"14812220909\", \"18403009099\"]}', 'id': 'call_1d9bb4562d03406297f9d3', 'index': 0, 'type': 'tool_call_chunk'}])]},\n {'steps': [AgentStep(action=ToolAgentAction(tool='send_sms', tool_input={'context': '明天下午到4楼会议室开会', 'phone_number': ['18502820900', '14812220909', '18403009099']}, log=\"\\nInvoking: `send_sms` with `{'context': '明天下午到4楼会议室开会', 'phone_number': ['18502820900', '14812220909', '18403009099']}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_1d9bb4562d03406297f9d3', 'function': {'arguments': '{\"context\": \"明天下午到4楼会议室开会\", \"phone_number\": [\"18502820900\", \"14812220909\", \"18403009099\"]}', 'name': 'send_sms'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6581bc85-f41e-477c-bc18-61b294f4e37b', tool_calls=[{'name': 'send_sms', 'args': {'context': '明天下午到4楼会议室开会', 'phone_number': ['18502820900', '14812220909', '18403009099']}, 'id': 'call_1d9bb4562d03406297f9d3', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'send_sms', 'args': '{\"context\": \"明天下午到4楼会议室开会\", \"phone_number\": [\"18502820900\", \"14812220909\", \"18403009099\"]}', 'id': 'call_1d9bb4562d03406297f9d3', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_1d9bb4562d03406297f9d3'), observation='发送成功')],\n  'messages': [FunctionMessage(content='发送成功', additional_kwargs={}, response_metadata={}, name='send_sms')]},\n {'output': '短信发送成功。内容是：明天下午到4楼会议室开会，已发送到手机号18502820900, 14812220909, 18403009099。',\n  'messages': [AIMessage(content='短信发送成功。内容是：明天下午到4楼会议室开会，已发送到手机号18502820900, 14812220909, 18403009099。', additional_kwargs={}, response_metadata={})]}]"
     },
     "execution_count": 75,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from langchain_core.runnables import RunnableLambda\n",
    "from langchain.agents.output_parsers.openai_tools import OpenAIToolsAgentOutputParser\n",
    "from langchain.agents.format_scratchpad.openai_tools import format_to_openai_tool_messages\n",
    "from langchain.agents import AgentExecutor\n",
    "\n",
    "\n",
    "def print_any(arg):\n",
    "    print(f\"输出：{arg}\")\n",
    "    return arg\n",
    "\n",
    "\n",
    "# 定义一个chain,\n",
    "# step1: 为prompt模板准备参数，从agent调用输入中提取input和intermediate_steps两个参数，input由用户输入，intermediate_steps由agent生成\n",
    "# step2: 根据step1的参数，格式化prompt template\n",
    "# step3: 调用模型\n",
    "# step4: 处理模型输出\n",
    "agent = ({\n",
    "             \"input\": lambda x: x[\"input\"],\n",
    "             \"agent_scratchpad\": lambda x: format_to_openai_tool_messages(x[\"intermediate_steps\"]),\n",
    "         }\n",
    "         | RunnableLambda(print_any) | prompt\n",
    "         | llm_with_tools\n",
    "         | OpenAIToolsAgentOutputParser()\n",
    "         )\n",
    "\n",
    "# 定义agent执行器\n",
    "agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)\n",
    "\n",
    "# 调用agent\n",
    "list(agent_executor.stream({\"input\": \"eudca这个单词有几个字母\"}))\n",
    "list(agent_executor.stream(\n",
    "    {\"input\": \"给手机号18502820900,14812220909,18403009099，发送短信内容：明天下午到4楼会议室开会\"}))\n"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-30T09:21:59.569261Z",
     "start_time": "2024-10-30T09:21:46.124195Z"
    }
   },
   "id": "b1f1565e328322e5",
   "execution_count": 75
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 为Agent增加记忆功能\n",
    "我们希望Agent记住之前说的内容，其实也很简单，就是把AI返回的内容插入到提示词(prompt)中一起提交给AI就行。\n",
    "### 修改提示词模板\n",
    "修改提示词模板，增加对话历史模板变量"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "c9a0c109faea1f48"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "prompt = ChatPromptTemplate.from_messages([\n",
    "    (\"system\",\n",
    "     \"你是一个非常强大的助手，但不了解当前事件。\"),\n",
    "    (\"human\", \"{input}\"),\n",
    "    MessagesPlaceholder(variable_name=\"agent_scratchpad\"),\n",
    "    MessagesPlaceholder(variable_name=\"chat_history\"),\n",
    "])"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-30T09:21:59.576010Z",
     "start_time": "2024-10-30T09:21:59.571168Z"
    }
   },
   "id": "2d331f89f6ba9159",
   "execution_count": 76
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 调用agent时，提供对话历史数据\n",
    "也可使用ConversationBufferMemory等方式实现"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "ac89795ecfc8b677"
  },
  {
   "cell_type": "code",
   "outputs": [],
   "source": [
    "\n",
    "from operator import itemgetter\n",
    "from langchain_core.runnables import RunnablePassthrough\n",
    "from langchain.memory import ConversationBufferMemory\n",
    "\n",
    "memory = ConversationBufferMemory(\n",
    "    return_messages=True, output_key=\"answer\", input_key=\"input\", memory_key=\"chat_history\"\n",
    ")\n",
    "# 添加输出键时，传入参数\n",
    "loaded_memory = RunnablePassthrough.assign(\n",
    "    chat_history=RunnableLambda(memory.load_memory_variables) | itemgetter(\"chat_history\")\n",
    ")\n"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-30T09:32:48.377361Z",
     "start_time": "2024-10-30T09:32:48.371708Z"
    }
   },
   "id": "cc11c4e18aa798bd",
   "execution_count": 86
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 修改agent流程\n",
    "修改agent流程定义，为提示词模板（prompt template）提供对话历史数据，如下代码，新增chat_history参数处理\n"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "1777e538a426b274"
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001B[1m> Entering new AgentExecutor chain...\u001B[0m\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [], 'chat_history': []}\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'agent_scratchpad': [], 'chat_history': []}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a378b88bdd5748cebfa120', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1d556f07-557e-4b2c-a61c-d7a0f82db43b', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a378b88bdd5748cebfa120', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a378b88bdd5748cebfa120', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_a378b88bdd5748cebfa120'), 5)], 'chat_history': []}\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a378b88bdd5748cebfa120', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1d556f07-557e-4b2c-a61c-d7a0f82db43b', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a378b88bdd5748cebfa120', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a378b88bdd5748cebfa120', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_a378b88bdd5748cebfa120')], 'chat_history': []}\n",
      "\u001B[32;1m\u001B[1;3m\"eudca\"这个单词有5个字母。\u001B[0m\n",
      "\n",
      "\u001B[1m> Finished chain.\u001B[0m\n",
      "{'input': 'eudca这个单词有几个字母', 'output': '\"eudca\"这个单词有5个字母。'}\n"
     ]
    }
   ],
   "source": [
    "from langchain_core.messages import get_buffer_string\n",
    "import os\n",
    "from langchain_core.tools import tool\n",
    "from dotenv import load_dotenv\n",
    "from langchain_openai import ChatOpenAI\n",
    "\n",
    "load_dotenv()\n",
    "llm = ChatOpenAI(\n",
    "    # 若没有配置环境变量，请用百炼API Key将下行替换为：api_key=\"sk-xxx\",\n",
    "    openai_api_key=os.getenv(\"DASHSCOPE_API_KEY\"),\n",
    "    openai_api_base=\"https://dashscope.aliyuncs.com/compatible-mode/v1\",\n",
    "    model_name=\"qwen-max\",\n",
    "    max_retries=0,\n",
    ")\n",
    "\n",
    "llm = tongyi\n",
    "@tool\n",
    "def get_word_length(word: str) -> int:\n",
    "    \"\"\"\n",
    "    计算Word长度并返回计算结果\n",
    "    :param word: \n",
    "    :return: \n",
    "    \"\"\"\n",
    "    return len(word)\n",
    "\n",
    "\n",
    "@tool\n",
    "def send_sms(context: str, phone_number: str | list[str]) -> str:\n",
    "    \"\"\"\n",
    "    发送短信\n",
    "    :param context: \n",
    "    :param phone_number: \n",
    "    :return: \n",
    "    \"\"\"\n",
    "    print(f\"发短信，短信内容为：{context} 发送对象:{phone_number}\")\n",
    "    return \"发送成功\"\n",
    "\n",
    "\n",
    "# 定义工具集\n",
    "tools = [get_word_length, send_sms]\n",
    "agent = (loaded_memory |RunnableLambda(print_any) | {\n",
    "    \"input\": lambda x: x[\"input\"],\n",
    "    \"agent_scratchpad\": lambda x: format_to_openai_tool_messages(x[\"intermediate_steps\"]),\n",
    "    \"chat_history\": lambda x: x[\"chat_history\"],\n",
    "}\n",
    "         | RunnableLambda(print_any) | prompt\n",
    "         | llm_with_tools\n",
    "         | OpenAIToolsAgentOutputParser()\n",
    "         )\n",
    "agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)\n",
    "input1 = {\"input\": \"eudca这个单词有几个字母\"}\n",
    "result = agent_executor.invoke(input1)\n",
    "print(result)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-30T09:42:35.065711Z",
     "start_time": "2024-10-30T09:42:31.936894Z"
    }
   },
   "id": "df33835d899ecc5e",
   "execution_count": 93
  },
  {
   "cell_type": "code",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\n",
      "\u001B[1m> Entering new AgentExecutor chain...\u001B[0m\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'agent_scratchpad': [], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64')], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b')], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})], 'input': 'eudca这个单词有几个字母'}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_8fd52e16c4ee494d93829a'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_8fd52e16c4ee494d93829a')], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_8fd52e16c4ee494d93829a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e93ec660fcff4f8eabbdb0'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})], 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_8fd52e16c4ee494d93829a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e93ec660fcff4f8eabbdb0')]}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_8fd52e16c4ee494d93829a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e93ec660fcff4f8eabbdb0'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9f0d2aeba8374c2a8ca44e'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_8fd52e16c4ee494d93829a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e93ec660fcff4f8eabbdb0'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9f0d2aeba8374c2a8ca44e')], 'input': 'eudca这个单词有几个字母', 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_8fd52e16c4ee494d93829a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e93ec660fcff4f8eabbdb0'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9f0d2aeba8374c2a8ca44e'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_3d08f0840c1f4d5faa96bb'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})], 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_8fd52e16c4ee494d93829a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e93ec660fcff4f8eabbdb0'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9f0d2aeba8374c2a8ca44e'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_3d08f0840c1f4d5faa96bb')], 'input': 'eudca这个单词有几个字母'}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_8fd52e16c4ee494d93829a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e93ec660fcff4f8eabbdb0'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9f0d2aeba8374c2a8ca44e'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_3d08f0840c1f4d5faa96bb'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_55ea4af473404cf394ce91'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_8fd52e16c4ee494d93829a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e93ec660fcff4f8eabbdb0'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9f0d2aeba8374c2a8ca44e'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_3d08f0840c1f4d5faa96bb'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_55ea4af473404cf394ce91')], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_8fd52e16c4ee494d93829a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e93ec660fcff4f8eabbdb0'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9f0d2aeba8374c2a8ca44e'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_3d08f0840c1f4d5faa96bb'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_55ea4af473404cf394ce91'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_a81c33cf7c55409a9d8409'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})], 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_8fd52e16c4ee494d93829a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e93ec660fcff4f8eabbdb0'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9f0d2aeba8374c2a8ca44e'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_3d08f0840c1f4d5faa96bb'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_55ea4af473404cf394ce91'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_a81c33cf7c55409a9d8409')]}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_8fd52e16c4ee494d93829a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e93ec660fcff4f8eabbdb0'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9f0d2aeba8374c2a8ca44e'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_3d08f0840c1f4d5faa96bb'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_55ea4af473404cf394ce91'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_a81c33cf7c55409a9d8409'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_b7ed43cd543545a398933f', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d1a82048-67e9-40ad-bcee-ca997b2d479a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_b7ed43cd543545a398933f', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_b7ed43cd543545a398933f', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_b7ed43cd543545a398933f'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})], 'input': 'eudca这个单词有几个字母', 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_8fd52e16c4ee494d93829a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e93ec660fcff4f8eabbdb0'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9f0d2aeba8374c2a8ca44e'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_3d08f0840c1f4d5faa96bb'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_55ea4af473404cf394ce91'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_a81c33cf7c55409a9d8409'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_b7ed43cd543545a398933f', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d1a82048-67e9-40ad-bcee-ca997b2d479a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_b7ed43cd543545a398933f', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_b7ed43cd543545a398933f', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_b7ed43cd543545a398933f')]}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_8fd52e16c4ee494d93829a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e93ec660fcff4f8eabbdb0'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9f0d2aeba8374c2a8ca44e'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_3d08f0840c1f4d5faa96bb'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_55ea4af473404cf394ce91'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_a81c33cf7c55409a9d8409'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_b7ed43cd543545a398933f', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d1a82048-67e9-40ad-bcee-ca997b2d479a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_b7ed43cd543545a398933f', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_b7ed43cd543545a398933f', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_b7ed43cd543545a398933f'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_241bc755698e45039a71f2', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-fb2db012-afd1-4717-b0d4-91ad59d1646a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_241bc755698e45039a71f2', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_241bc755698e45039a71f2', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_241bc755698e45039a71f2'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})], 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_8fd52e16c4ee494d93829a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e93ec660fcff4f8eabbdb0'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9f0d2aeba8374c2a8ca44e'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_3d08f0840c1f4d5faa96bb'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_55ea4af473404cf394ce91'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_a81c33cf7c55409a9d8409'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_b7ed43cd543545a398933f', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d1a82048-67e9-40ad-bcee-ca997b2d479a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_b7ed43cd543545a398933f', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_b7ed43cd543545a398933f', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_b7ed43cd543545a398933f'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_241bc755698e45039a71f2', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-fb2db012-afd1-4717-b0d4-91ad59d1646a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_241bc755698e45039a71f2', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_241bc755698e45039a71f2', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_241bc755698e45039a71f2')]}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_8fd52e16c4ee494d93829a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e93ec660fcff4f8eabbdb0'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9f0d2aeba8374c2a8ca44e'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_3d08f0840c1f4d5faa96bb'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_55ea4af473404cf394ce91'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_a81c33cf7c55409a9d8409'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_b7ed43cd543545a398933f', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d1a82048-67e9-40ad-bcee-ca997b2d479a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_b7ed43cd543545a398933f', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_b7ed43cd543545a398933f', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_b7ed43cd543545a398933f'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_241bc755698e45039a71f2', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-fb2db012-afd1-4717-b0d4-91ad59d1646a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_241bc755698e45039a71f2', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_241bc755698e45039a71f2', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_241bc755698e45039a71f2'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-0603a1ca-0e8a-44b2-8053-a27564e6ff28', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_46cdcdeefa6f4ff1bedc8a'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})], 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_8fd52e16c4ee494d93829a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e93ec660fcff4f8eabbdb0'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9f0d2aeba8374c2a8ca44e'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_3d08f0840c1f4d5faa96bb'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_55ea4af473404cf394ce91'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_a81c33cf7c55409a9d8409'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_b7ed43cd543545a398933f', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d1a82048-67e9-40ad-bcee-ca997b2d479a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_b7ed43cd543545a398933f', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_b7ed43cd543545a398933f', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_b7ed43cd543545a398933f'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_241bc755698e45039a71f2', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-fb2db012-afd1-4717-b0d4-91ad59d1646a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_241bc755698e45039a71f2', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_241bc755698e45039a71f2', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_241bc755698e45039a71f2'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-0603a1ca-0e8a-44b2-8053-a27564e6ff28', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_46cdcdeefa6f4ff1bedc8a')], 'input': 'eudca这个单词有几个字母'}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_8fd52e16c4ee494d93829a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e93ec660fcff4f8eabbdb0'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9f0d2aeba8374c2a8ca44e'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_3d08f0840c1f4d5faa96bb'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_55ea4af473404cf394ce91'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_a81c33cf7c55409a9d8409'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_b7ed43cd543545a398933f', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d1a82048-67e9-40ad-bcee-ca997b2d479a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_b7ed43cd543545a398933f', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_b7ed43cd543545a398933f', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_b7ed43cd543545a398933f'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_241bc755698e45039a71f2', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-fb2db012-afd1-4717-b0d4-91ad59d1646a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_241bc755698e45039a71f2', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_241bc755698e45039a71f2', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_241bc755698e45039a71f2'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-0603a1ca-0e8a-44b2-8053-a27564e6ff28', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_46cdcdeefa6f4ff1bedc8a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9c7bd7efcca74521b95d7a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-8235f3ba-c5c2-4862-a514-e54d6b43522b', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9c7bd7efcca74521b95d7a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9c7bd7efcca74521b95d7a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9c7bd7efcca74521b95d7a'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})], 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_8fd52e16c4ee494d93829a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e93ec660fcff4f8eabbdb0'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9f0d2aeba8374c2a8ca44e'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_3d08f0840c1f4d5faa96bb'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_55ea4af473404cf394ce91'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_a81c33cf7c55409a9d8409'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_b7ed43cd543545a398933f', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d1a82048-67e9-40ad-bcee-ca997b2d479a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_b7ed43cd543545a398933f', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_b7ed43cd543545a398933f', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_b7ed43cd543545a398933f'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_241bc755698e45039a71f2', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-fb2db012-afd1-4717-b0d4-91ad59d1646a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_241bc755698e45039a71f2', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_241bc755698e45039a71f2', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_241bc755698e45039a71f2'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-0603a1ca-0e8a-44b2-8053-a27564e6ff28', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_46cdcdeefa6f4ff1bedc8a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9c7bd7efcca74521b95d7a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-8235f3ba-c5c2-4862-a514-e54d6b43522b', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9c7bd7efcca74521b95d7a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9c7bd7efcca74521b95d7a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9c7bd7efcca74521b95d7a')]}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_8fd52e16c4ee494d93829a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e93ec660fcff4f8eabbdb0'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9f0d2aeba8374c2a8ca44e'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_3d08f0840c1f4d5faa96bb'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_55ea4af473404cf394ce91'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_a81c33cf7c55409a9d8409'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_b7ed43cd543545a398933f', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d1a82048-67e9-40ad-bcee-ca997b2d479a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_b7ed43cd543545a398933f', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_b7ed43cd543545a398933f', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_b7ed43cd543545a398933f'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_241bc755698e45039a71f2', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-fb2db012-afd1-4717-b0d4-91ad59d1646a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_241bc755698e45039a71f2', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_241bc755698e45039a71f2', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_241bc755698e45039a71f2'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-0603a1ca-0e8a-44b2-8053-a27564e6ff28', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_46cdcdeefa6f4ff1bedc8a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9c7bd7efcca74521b95d7a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-8235f3ba-c5c2-4862-a514-e54d6b43522b', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9c7bd7efcca74521b95d7a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9c7bd7efcca74521b95d7a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9c7bd7efcca74521b95d7a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_de4b444945f54f44a528ab', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-634154ce-1980-48db-a19f-95bc73756352', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_de4b444945f54f44a528ab', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_de4b444945f54f44a528ab', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_de4b444945f54f44a528ab'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'input': 'eudca这个单词有几个字母', 'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_8fd52e16c4ee494d93829a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e93ec660fcff4f8eabbdb0'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9f0d2aeba8374c2a8ca44e'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_3d08f0840c1f4d5faa96bb'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_55ea4af473404cf394ce91'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_a81c33cf7c55409a9d8409'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_b7ed43cd543545a398933f', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d1a82048-67e9-40ad-bcee-ca997b2d479a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_b7ed43cd543545a398933f', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_b7ed43cd543545a398933f', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_b7ed43cd543545a398933f'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_241bc755698e45039a71f2', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-fb2db012-afd1-4717-b0d4-91ad59d1646a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_241bc755698e45039a71f2', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_241bc755698e45039a71f2', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_241bc755698e45039a71f2'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-0603a1ca-0e8a-44b2-8053-a27564e6ff28', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_46cdcdeefa6f4ff1bedc8a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9c7bd7efcca74521b95d7a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-8235f3ba-c5c2-4862-a514-e54d6b43522b', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9c7bd7efcca74521b95d7a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9c7bd7efcca74521b95d7a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9c7bd7efcca74521b95d7a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_de4b444945f54f44a528ab', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-634154ce-1980-48db-a19f-95bc73756352', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_de4b444945f54f44a528ab', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_de4b444945f54f44a528ab', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_de4b444945f54f44a528ab')], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m输出：{'input': 'eudca这个单词有几个字母', 'intermediate_steps': [(ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_31a6fc6e36e44fbf876a64'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e3160f694d0a434d8e5b4b'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_8fd52e16c4ee494d93829a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_e93ec660fcff4f8eabbdb0'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9f0d2aeba8374c2a8ca44e'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_3d08f0840c1f4d5faa96bb'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_55ea4af473404cf394ce91'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_a81c33cf7c55409a9d8409'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_b7ed43cd543545a398933f', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d1a82048-67e9-40ad-bcee-ca997b2d479a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_b7ed43cd543545a398933f', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_b7ed43cd543545a398933f', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_b7ed43cd543545a398933f'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_241bc755698e45039a71f2', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-fb2db012-afd1-4717-b0d4-91ad59d1646a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_241bc755698e45039a71f2', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_241bc755698e45039a71f2', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_241bc755698e45039a71f2'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-0603a1ca-0e8a-44b2-8053-a27564e6ff28', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_46cdcdeefa6f4ff1bedc8a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9c7bd7efcca74521b95d7a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-8235f3ba-c5c2-4862-a514-e54d6b43522b', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9c7bd7efcca74521b95d7a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9c7bd7efcca74521b95d7a', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_9c7bd7efcca74521b95d7a'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_de4b444945f54f44a528ab', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-634154ce-1980-48db-a19f-95bc73756352', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_de4b444945f54f44a528ab', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_de4b444945f54f44a528ab', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_de4b444945f54f44a528ab'), 5), (ToolAgentAction(tool='get_word_length', tool_input={'word': 'eudca'}, log=\"\\nInvoking: `get_word_length` with `{'word': 'eudca'}`\\n\\n\\n\", message_log=[AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_bb19fd0a512c43afb27558', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-e7498720-0fee-489c-9301-0fa2cc18ff5e', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_bb19fd0a512c43afb27558', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_bb19fd0a512c43afb27558', 'index': 0, 'type': 'tool_call_chunk'}])], tool_call_id='call_bb19fd0a512c43afb27558'), 5)], 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "输出：{'agent_scratchpad': [AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_31a6fc6e36e44fbf876a64', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-c6406776-9e36-4bd9-b2c3-bed459c1d36f', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_31a6fc6e36e44fbf876a64', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_31a6fc6e36e44fbf876a64', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_31a6fc6e36e44fbf876a64'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e3160f694d0a434d8e5b4b', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-4ee5c568-b14a-4557-9d67-2113ef35dd4d', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e3160f694d0a434d8e5b4b', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e3160f694d0a434d8e5b4b', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e3160f694d0a434d8e5b4b'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_8fd52e16c4ee494d93829a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-f17336b5-7dd1-491f-a759-9a389c06d884', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_8fd52e16c4ee494d93829a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_8fd52e16c4ee494d93829a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_8fd52e16c4ee494d93829a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_e93ec660fcff4f8eabbdb0', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d5ceef75-2a70-45b2-94da-15f4166175ab', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_e93ec660fcff4f8eabbdb0', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_e93ec660fcff4f8eabbdb0', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_e93ec660fcff4f8eabbdb0'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-a418438a-825e-4ec7-a776-ed4be7d60a70', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9f0d2aeba8374c2a8ca44e', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9f0d2aeba8374c2a8ca44e', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9f0d2aeba8374c2a8ca44e'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_3d08f0840c1f4d5faa96bb', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-97daa7eb-c8b8-44f2-bd85-925655931ed0', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_3d08f0840c1f4d5faa96bb', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_3d08f0840c1f4d5faa96bb', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_3d08f0840c1f4d5faa96bb'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_55ea4af473404cf394ce91', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-1143b8f4-2765-454d-a991-f36e6e93c2af', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_55ea4af473404cf394ce91', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_55ea4af473404cf394ce91', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_55ea4af473404cf394ce91'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_a81c33cf7c55409a9d8409', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-6de5dd1b-03a9-401a-8deb-1ffeb13becb7', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_a81c33cf7c55409a9d8409', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_a81c33cf7c55409a9d8409', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_a81c33cf7c55409a9d8409'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_b7ed43cd543545a398933f', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-d1a82048-67e9-40ad-bcee-ca997b2d479a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_b7ed43cd543545a398933f', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_b7ed43cd543545a398933f', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_b7ed43cd543545a398933f'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_241bc755698e45039a71f2', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-fb2db012-afd1-4717-b0d4-91ad59d1646a', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_241bc755698e45039a71f2', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_241bc755698e45039a71f2', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_241bc755698e45039a71f2'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-0603a1ca-0e8a-44b2-8053-a27564e6ff28', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_46cdcdeefa6f4ff1bedc8a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_46cdcdeefa6f4ff1bedc8a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_9c7bd7efcca74521b95d7a', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-8235f3ba-c5c2-4862-a514-e54d6b43522b', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_9c7bd7efcca74521b95d7a', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_9c7bd7efcca74521b95d7a', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_9c7bd7efcca74521b95d7a'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_de4b444945f54f44a528ab', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-634154ce-1980-48db-a19f-95bc73756352', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_de4b444945f54f44a528ab', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_de4b444945f54f44a528ab', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_de4b444945f54f44a528ab'), AIMessageChunk(content='', additional_kwargs={'tool_calls': [{'index': 0, 'id': 'call_bb19fd0a512c43afb27558', 'function': {'arguments': '{\"word\": \"eudca\"}', 'name': 'get_word_length'}, 'type': 'function'}]}, response_metadata={'finish_reason': 'tool_calls', 'model_name': 'qwen-max'}, id='run-e7498720-0fee-489c-9301-0fa2cc18ff5e', tool_calls=[{'name': 'get_word_length', 'args': {'word': 'eudca'}, 'id': 'call_bb19fd0a512c43afb27558', 'type': 'tool_call'}], tool_call_chunks=[{'name': 'get_word_length', 'args': '{\"word\": \"eudca\"}', 'id': 'call_bb19fd0a512c43afb27558', 'index': 0, 'type': 'tool_call_chunk'}]), ToolMessage(content='5', tool_call_id='call_bb19fd0a512c43afb27558')], 'input': 'eudca这个单词有几个字母', 'chat_history': [HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={}), HumanMessage(content='eudca这个单词有几个字母', additional_kwargs={}, response_metadata={}), AIMessage(content='\"eudca\"这个单词有5个字母。', additional_kwargs={}, response_metadata={})]}\n",
      "\u001B[32;1m\u001B[1;3m\n",
      "Invoking: `get_word_length` with `{'word': 'eudca'}`\n",
      "\n",
      "\n",
      "\u001B[0m\u001B[36;1m\u001B[1;3m5\u001B[0m\u001B[32;1m\u001B[1;3m\u001B[0m\n",
      "\n",
      "\u001B[1m> Finished chain.\u001B[0m\n"
     ]
    },
    {
     "data": {
      "text/plain": "{'input': 'eudca这个单词有几个字母', 'output': 'Agent stopped due to max iterations.'}"
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 回答结果存储\n",
    "memory.save_context(input1, {\"answer\": result[\"output\"]})\n",
    "# 查看存储信息\n",
    "memory.load_memory_variables({})\n",
    "\n",
    "# 再次调用agent，同时传入对话历史数据\n",
    "agent_executor.invoke(input1)"
   ],
   "metadata": {
    "collapsed": false,
    "ExecuteTime": {
     "end_time": "2024-10-30T09:46:31.714045Z",
     "start_time": "2024-10-30T09:45:58.909190Z"
    }
   },
   "id": "98a8e9e2b6d6002d",
   "execution_count": 97
  },
  {
   "cell_type": "markdown",
   "source": [
    "实际业务场景，你可以把对话历史保存到数据库中，根据业务需要把数据插入到提示词(prompt)中即可。\n",
    "\n",
    "> 提示：大模型(LLM)的记忆功能，目前基本上都是通过把历史对话(chat history)内容插入到提示词(prompt)中提交给LLM实现，LangChain只是提供了一些封装，你可以选择不使用，自己把对话历史拼接到提示词模板(prompt template)即可。"
   ],
   "metadata": {
    "collapsed": false
   },
   "id": "a7a4a85bceeb56ae"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
